﻿using B.S.Material.ErrorCode;
using B.S.Material.Wirth.Api.Applications.Command.ScrapBreakdownCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Material.Wirth.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ScrapBreakdownController : ControllerBase
    {
        private readonly IMediator mediator;
        public ScrapBreakdownController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 废料明细添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<object>> AddScrapBreakdown(AddScrapBreakdownCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 废料明细修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult<int>> DelScrapBreakdown(DelScrapBreakdownCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 废料明细删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateScrapBreakdown(UpdateScrapBreakdownCommand request)
        {
            return await mediator.Send(request);
        }


    }
}
